<!--
 * @Descripttion: 
 * @version: 
 * @Author: Eugene
 * @Date: 2022-12-07 22:27:17
 * @LastEditors: Andy
 * @LastEditTime: 2022-12-11 23:43:14
-->
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body></body>
<script>
  // 将data中的数据的key按照改为指定的英文 
        // 思考如何将data中数据转化为最终输出的结果
        const data = [
            {
                入职日期: 44505,
                姓名: "小张",
                工号: "9002",
                手机号: "13800000252",
                转正日期: 44892,
                部门: "总裁办"
            },
            {
                入职日期: 44506,
                姓名: "小李",
                工号: 9006,
                手机号: "13810000512",
                转正日期: 44893,
                部门: "总裁办",
            }

        ]
        function dataFormat(data){
        // 1. 映射对象，根据映射对象找英文的键
        const mapInfo = {
                '入职日期': 'timeOfEntry',
                '手机号': 'mobile',
                '姓名': 'username',
                '转正日期': 'correctionTime',
                '工号': 'workNumber',
                '部门': 'departmentName',
                '聘用形式': 'formOfEmployment'
            }
        // 遍历data得到每一个对象
        const result = data.map(zhObj=>{
          const enObj = {} //放英文的值
          const zhkeys = Object.keys(zhObj)
          console.log('zhkeys',zhkeys) //['入职日期', '姓名', '工号', '手机号', '转正日期', '部门']
          zhkeys.forEach(zhkey => {
            console.log('mapInfo[zhkey]',mapInfo[zhkey]) //得到对应的英文键
            enObj[mapInfo[zhkey]] = zhObj[zhkey]
            // console.log('enObj[mapInfo[zhkey]] = zhObj[zhkey]',enObj[mapInfo[zhkey]] = zhObj[zhkey])
          })
           return enObj
          //  console.log('enObj',enObj)
        })
        return result
        }
        const result =  dataFormat(data)
       console.log(result)


      //  hhhhhhhzhangzhangzhang
</script>
</html>